import { createRouter, createWebHistory } from 'vue-router'
import AdminLayout from '../layouts/MainLayout.vue'
// 仪表盘
import Dashboard from '../views/dashboard/Dashboard.vue'
import DashboardNew from '../views/dashboard/DashboardNew.vue'
import OverviewPage from '../views/dashboard/OverviewPage.vue'
import WorkspaceAnalysis from '../views/dashboard/WorkspaceAnalysis.vue'
// 系统监控
import SystemMonitor from '../views/system/SystemMonitor.vue'
// 模板
import TemplateList from '../views/templates/TemplateList.vue'
import TemplateCreate from '../views/templates/TemplateCreate.vue'
// 组件
import ComponentBasic from '../views/components/ComponentBasicEnhanced.vue'
import ComponentAdvanced from '../views/components/ComponentAdvancedNew.vue'
import ComponentCharts from '../views/components/ComponentCharts.vue'
import IconShowcase from '../views/components/IconShowcase.vue'
// 表单
import FormBasic from '../views/forms/FormBasic.vue'
// 表格
import TableBasic from '../views/tables/TableBasic.vue'
// 用户管理
import UserList from '../views/users/UserList.vue'
// 通用页面
import AboutView from '../views/pages/AboutView.vue'
import HomeView from '../views/pages/HomeView.vue'

// 创建一个通用的页面组件用于演示
const createDemoPage = (title, content) => ({
  template: `
    <div style="padding: 20px;">
      <el-card>
        <template #header>
          <h2>${title}</h2>
        </template>
        <div style="padding: 40px; text-align: center; color: #666;">
          <el-icon size="48" style="margin-bottom: 16px;"><Document /></el-icon>
          <p style="font-size: 16px;">${content}</p>
          <p style="margin-top: 16px; font-size: 14px;">页面正在开发中...</p>
        </div>
      </el-card>
    </div>
  `
})

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/old-dashboard',
      name: 'OldDashboard',
      component: Dashboard
    },
    {
      path: '/',
      component: AdminLayout,
      redirect: '/dashboard',
      children: [
        // 仪表盘
        {
          path: 'dashboard',
          name: 'Dashboard',
          component: OverviewPage,
          meta: { title: '概览', icon: 'House' }
        },
        {
          path: 'dashboard/analysis',
          name: 'DashboardAnalysis',
          component: WorkspaceAnalysis,
          meta: { title: '分析页', icon: 'House' }
        },
        {
          path: 'dashboard/monitor',
          name: 'DashboardMonitor',
          component: SystemMonitor,
          meta: { title: '监控页', icon: 'House' }
        },
        
        // 模板中心
        {
          path: 'template/list',
          name: 'TemplateList',
          component: TemplateList,
          meta: { title: '模板列表', icon: 'Grid' }
        },
        {
          path: 'template/create',
          name: 'TemplateCreate',
          component: TemplateCreate,
          meta: { title: '创建模板', icon: 'Grid' }
        },
        
        // 组件中心
        {
          path: 'component/basic',
          name: 'ComponentBasic',
          component: ComponentBasic,
          meta: { title: '基础组件', icon: 'Operation' }
        },
        {
          path: 'component/advanced',
          name: 'ComponentAdvanced',
          component: ComponentAdvanced,
          meta: { title: '高级组件', icon: 'Operation' }
        },
        {
          path: 'component/charts',
          name: 'ComponentCharts',
          component: ComponentCharts,
          meta: { title: '图表组件', icon: 'TrendCharts' }
        },
        {
          path: 'component/icons',
          name: 'ComponentIcons',
          component: IconShowcase,
          meta: { title: '图标组件', icon: 'Star' }
        },
        
        // 功能示例
        {
          path: 'examples/forms',
          name: 'ExamplesForms',
          component: FormBasic,
          meta: { title: '表单示例', icon: 'Promotion' }
        },
        {
          path: 'examples/tables',
          name: 'ExamplesTables',
          component: TableBasic,
          meta: { title: '表格示例', icon: 'Promotion' }
        },
        {
          path: 'examples/charts',
          name: 'ExamplesCharts',
          component: createDemoPage('图表示例', '各种图表使用示例'),
          meta: { title: '图表示例', icon: 'Promotion' }
        },
        {
          path: 'examples/flow',
          name: 'ExamplesFlow',
          component: createDemoPage('流程示例', '业务流程处理示例'),
          meta: { title: '流程示例', icon: 'Promotion' }
        },
        
        // 系统管理
        {
          path: 'system/users',
          name: 'SystemUsers',
          component: UserList,
          meta: { title: '用户管理', icon: 'Setting' }
        },
        {
          path: 'system/roles',
          name: 'SystemRoles',
          component: createDemoPage('角色管理', '管理用户角色'),
          meta: { title: '角色管理', icon: 'Setting' }
        },
        {
          path: 'system/permissions',
          name: 'SystemPermissions',
          component: createDemoPage('权限管理', '管理系统权限'),
          meta: { title: '权限管理', icon: 'Setting' }
        },
        {
          path: 'system/settings',
          name: 'SystemSettings',
          component: createDemoPage('系统设置', '系统参数配置'),
          meta: { title: '系统设置', icon: 'Setting' }
        },
        
        // 文章管理
        {
          path: 'article/list',
          name: 'ArticleList',
          component: createDemoPage('文章列表', '查看所有文章'),
          meta: { title: '文章列表', icon: 'EditPen' }
        },
        {
          path: 'article/create',
          name: 'ArticleCreate',
          component: createDemoPage('创建文章', '发布新文章'),
          meta: { title: '创建文章', icon: 'EditPen' }
        },
        {
          path: 'article/categories',
          name: 'ArticleCategories',
          component: createDemoPage('分类管理', '管理文章分类'),
          meta: { title: '分类管理', icon: 'EditPen' }
        },
        {
          path: 'article/tags',
          name: 'ArticleTags',
          component: createDemoPage('标签管理', '管理文章标签'),
          meta: { title: '标签管理', icon: 'EditPen' }
        },
        
        // 其他页面
        {
          path: 'changelog',
          name: 'Changelog',
          component: createDemoPage('更新日志', '查看系统更新记录'),
          meta: { title: '更新日志', icon: 'Calendar' }
        }
      ]
    }
  ]
})

export default router
